#include <stdio.h>
#define MIN(m,n) ((m<n)?m:n)
#define MAX(m,n) ((m>n)?m:n)
#define FOR(i, a, n) for(i=a;i<n;i++)
void swap1(int &i, int &j)
{
    int temp = i;
    i = j;
    j = temp;
}

void swap2(int a[][1], int i, int j, int k)
{
    int temp;
    temp = a[i][k];
    a[i][k] = a[j][k];
    a[j][k] =temp;
}


void b1()
{
    unsigned int testCases;
    int n, i, j;
    int a[100];
    int checkSum=0;
    int checkMax;

    scanf("%d", &testCases);
    while (testCases-- && testCases <= 20 )
    {
        scanf("%d", &n);
        if ( n<=100 && n>0)
        {
            FOR(i, 0, n)
            {
                scanf("%d", &a[i]);
            }
            FOR(i, 0, n-1)
            {
                FOR(j, i+1, n)
                {
                    if (a[i] < a[j])
                    {
                        swap1(a[i], a[j]);
                    }
                }
            }
            FOR (i, 0, n-1)
            {
                int cal=1;
                FOR (j, i+1, n)
                {
                    if (a[i] == a[j])
                    {
                        cal++;
                    }
                }

                if (cal>checkSum)
                {
                    checkSum = cal;
                    checkMax = a[i];
                }
            }
        }
        FOR (i, 0, n)
        {
            if (a[i] == checkMax)
            {
                printf("%d", i+1);
                break;
            }
        }
    }
}

int findS(int n)
{
    int i, sum=0;
    FOR(i,1,n)
    {
        if (n%i==0)
        {
            sum++;
        }
    }
    return sum;
}

int checkMax(int a[], int len, int k)
{
    int i, result;
    int nSmall = -1, nGreat = -1;
    int maxN= a[0];
    maxN=a[0];
    FOR(i, 1, len)
    {
        if (a[i] > maxN)
        {
            maxN=a[i];
        }
    }
    FOR(i, 0, len)
    {
        if (a[i]>=maxN)
        {
            nSmall++;
        }
        if (a[i]<=maxN)
        {
            nGreat++;
        }
    }
    FOR(i, 0, len)
    {
        if (a[i] == maxN && nSmall >= k && nGreat >= (len-k))
        {
            result = i;
            break;
        }
    }
    return result;
}

void b3()
{
    unsigned int testCases, L, R, K, i, len=0;
    int aNum[100];
    int aDiv[100];
    int result;

    scanf("%d", &testCases);

    while (testCases-- && testCases <= 20 )
    {
        scanf("%d %d %d", &L, &R, &K);

        if (L<=R && K<=(R-L+1))
        {
            FOR(i, L, R+1)
            {
                aNum[len] = i;
                aDiv[len] = findS(i);
                len++;
            }
            result = checkMax(aDiv, len, K);
            printf("\n%d %d", aNum[result], aDiv[result]);

        }
    }
}

int main()
{
    b3();
}

